import { ApiProperty } from '@nestjs/swagger';
import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export abstract class BaseEntity {
  @ApiProperty({ type: String, description: '主键' })
  @PrimaryGeneratedColumn({
    comment: '主键',
    type: 'bigint',
    primaryKeyConstraintName: 'entity_id',
  })
  public id: number;

  @ApiProperty({ type: String, description: '状态' })
  @Column({ type: 'char', name: 'status', default: '0', length: 1, comment: '状态 0正常 1停用' })
  public status: '0' | '1';

  @ApiProperty({ type: String, description: '是否删除' })
  @Column({
    type: 'char',
    name: 'is_delete',
    default: '0',
    length: 1,
    comment: '是否删除 0未删除 1已删除',
  })
  public isDelete: '0' | '1';

  @ApiProperty({ type: Date, description: '创建时间' })
  @CreateDateColumn({ type: 'datetime', name: 'create_time', comment: '创建时间' })
  public createTime: Date;

  @ApiProperty({ type: Date, description: '更新时间' })
  @UpdateDateColumn({ type: 'datetime', name: 'update_time', comment: '更新时间' })
  public updateTime: Date;

  @ApiProperty({ type: String, description: '备注' })
  @Column({ type: 'varchar', name: 'note', length: 255, comment: '备注', default: '' })
  public note: string;
}
